package main

import (
	"fmt"
)

type Phone interface {
	call()
}

type NokiaPhone struct{}
type IPhone struct{}

func (nokiaPhone NokiaPhone) call() {
	fmt.Println("I am Nokia, I can call you!")
}

func (iPhone IPhone) call() {
	fmt.Println("I am iPhone, I can call you!")
}

type Shaper interface {
	Area() float32
}
type Square struct {
	side float32
}

func (sq *Square) Area() float32 {
	return sq.side * sq.side
}
func main16() {
	var phone Phone

	phone = new(NokiaPhone)
	phone.call()

	phone = new(IPhone)
	phone.call()

	sq1 := new(Square)
	sq1.side = 5
	// 赋值方法1：
	// var areaIntf Shaper
	// areaIntf = sq1
	// 更短的赋值方法2:
	// areaIntf := Shaper(sq1)
	// 最简洁的赋值方法3：
	areaIntf := sq1
	fmt.Printf("The square has area: %f\n", areaIntf.Area())

}
